#ifndef __DFS_MESSAGE_H
#define __DFS_MESSAGE_H 1

struct dfs_mount;

extern __printf(2, 3)
void dfs_emerg(const struct dfs_mount *mp, const char *fmt, ...);
extern __printf(2, 3)
void dfs_alert(const struct dfs_mount *mp, const char *fmt, ...);
extern __printf(3, 4)
void dfs_alert_tag(const struct dfs_mount *mp, int tag, const char *fmt, ...);
extern __printf(2, 3)
void dfs_crit(const struct dfs_mount *mp, const char *fmt, ...);
extern __printf(2, 3)
void dfs_err(const struct dfs_mount *mp, const char *fmt, ...);
extern __printf(2, 3)
void dfs_warn(const struct dfs_mount *mp, const char *fmt, ...);
extern __printf(2, 3)
void dfs_notice(const struct dfs_mount *mp, const char *fmt, ...);
extern __printf(2, 3)
void dfs_info(const struct dfs_mount *mp, const char *fmt, ...);

#ifdef DEBUG
extern __printf(2, 3)
void dfs_debug(const struct dfs_mount *mp, const char *fmt, ...);
#else
static inline __printf(2, 3)
void dfs_debug(const struct dfs_mount *mp, const char *fmt, ...)
{
}
#endif

#define dfs_printk_ratelimited(func, dev, fmt, ...)		\
do {									\
	static DEFINE_RATELIMIT_STATE(_rs,				\
				      DEFAULT_RATELIMIT_INTERVAL,	\
				      DEFAULT_RATELIMIT_BURST);		\
	if (__ratelimit(&_rs))						\
		func(dev, fmt, ##__VA_ARGS__);			\
} while (0)

#define dfs_emerg_ratelimited(dev, fmt, ...)				\
	dfs_printk_ratelimited(dfs_emerg, dev, fmt, ##__VA_ARGS__)
#define dfs_alert_ratelimited(dev, fmt, ...)				\
	dfs_printk_ratelimited(dfs_alert, dev, fmt, ##__VA_ARGS__)
#define dfs_crit_ratelimited(dev, fmt, ...)				\
	dfs_printk_ratelimited(dfs_crit, dev, fmt, ##__VA_ARGS__)
#define dfs_err_ratelimited(dev, fmt, ...)				\
	dfs_printk_ratelimited(dfs_err, dev, fmt, ##__VA_ARGS__)
#define dfs_warn_ratelimited(dev, fmt, ...)				\
	dfs_printk_ratelimited(dfs_warn, dev, fmt, ##__VA_ARGS__)
#define dfs_notice_ratelimited(dev, fmt, ...)				\
	dfs_printk_ratelimited(dfs_notice, dev, fmt, ##__VA_ARGS__)
#define dfs_info_ratelimited(dev, fmt, ...)				\
	dfs_printk_ratelimited(dfs_info, dev, fmt, ##__VA_ARGS__)
#define dfs_debug_ratelimited(dev, fmt, ...)				\
	dfs_printk_ratelimited(dfs_debug, dev, fmt, ##__VA_ARGS__)

extern void assfail(char *expr, char *f, int l);
extern void asswarn(char *expr, char *f, int l);

extern void dfs_hex_dump(void *p, int length);

#endif	/* __DFS_MESSAGE_H */
